package org.jeecg.enums.meter;

/**
 * 仪表类型
 */
public enum MeterTypeEnum {
    METER_TYPE_ELECTRICITY(1, "电表","度"),
    METER_TYPE_WATER(2, "水表","吨");

    private Integer code;
    private String desc;
    private String unit;

    MeterTypeEnum(Integer code, String desc,String unit) {
        this.code = code;
        this.desc = desc;
        this.unit = unit;
    }

    public Integer getCode() {
        return code;
    }

    public String getDesc() {
        return desc;
    }

    public String getUnit() {
        return unit;
    }

    public static String getDesc(Integer value) {
        if (value == null) return "";
        MeterTypeEnum[] enums = values();
        for (MeterTypeEnum typeEnum : enums) {
            if (value.intValue() == typeEnum.getCode().intValue()) {
                return typeEnum.desc;
            }
        }
        return "";
    }

    public static String getUnit(Integer value) {
        if (value == null) return "";
        MeterTypeEnum[] enums = values();
        for (MeterTypeEnum typeEnum : enums) {
            if (value.intValue() == typeEnum.getCode().intValue()) {
                return typeEnum.unit;
            }
        }
        return "";
    }

    public static Integer getValue(String desc) {
        MeterTypeEnum[] enums = values();
        for (MeterTypeEnum typeEnum : enums) {
            if (typeEnum.getDesc().equals(desc)) {
                return typeEnum.code;
            }
        }
        return null;
    }
}
